package com.caac.core.web.action.user;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.caac.core.dm.Role;
import com.caac.core.web.action.BaseAction;
import com.caac.core.web.form.BaseForm;
import com.caac.core.web.form.RoleForm;

import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class AddRoleAction extends BaseAction {

    protected ActionForward doExecute(ActionMapping mapping, BaseForm form,
                                      HttpServletRequest request,
                                      HttpServletResponse response) throws java.
            lang.Exception {
        RoleForm rf = (RoleForm) form;
        String id = request.getParameter("id"); 
        if (id == null) {
            rf.setRole(new Role());
        } else {
            rf.setRole(this.getUserManager().getRoleById(id));
        }
        return this.forward(mapping);
    }
}
